package cn.monkey.io.transport.netty.duplex;

import cn.monkey.io.transport.core.Outbound;
import cn.monkey.io.transport.netty.NettyInbound;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.function.Predicate;


/**
 * 将 nettyInbound中读取到的数据转发到Outbound里
 */
public interface DuplexInbound extends NettyInbound, Outbound {

    NettyInbound nettyInbound();

    Outbound outbound();

    @Override
    default <T> Flux<T> receive(Class<T> clazz, Predicate<T> p) {
        return this.nettyInbound().receive(clazz, p);
    }

    default Mono<Void> writeAndFlush(Object o) {
        return this.outbound().writeAndFlush(o);
    }

    @Override
    default Mono<Void> write(Object o) {
        return this.outbound().write(o);
    }

    @Override
    default Mono<Void> flush() {
        return this.outbound().flush();
    }
}
